package com.whlilong.jxc.ui.provider;

import java.util.List;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import com.whlilong.jxc.treemodel.BrandInfoTreeChildren;
import com.whlilong.jxc.treemodel.BrandInfoTreeParent;
import com.whlilong.jxc.treemodel.DepartInfoTreeChildren;
import com.whlilong.jxc.treemodel.DepartInfoTreeParent;

public class DepartInfoTreeContentProvider implements ITreeContentProvider {

	@Override
	public Object[] getChildren(Object parentElement) {
		if (parentElement instanceof DepartInfoTreeParent)
			return ((DepartInfoTreeParent) parentElement).getDepartInfoTreeChildren()
					.toArray();
		return new Object[0];
	}

	@Override
	public Object getParent(Object element) {
		if(element instanceof DepartInfoTreeChildren)
			return ((DepartInfoTreeChildren)element).getDepartInfoTreeParent();
		return null;
	}

	@Override
	public boolean hasChildren(Object element) {
		// TODO Auto-generated method stub
		return getChildren(element).length>0;
	}

	@Override
	public Object[] getElements(Object inputElement) {
		// TODO Auto-generated method stub
		return ((List)inputElement).toArray();
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		// TODO Auto-generated method stub

	}

}
